package br.com.evolution.util;

import java.io.File;
import javax.swing.JOptionPane;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.wc.ISVNEventHandler;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNUpdateClient;

public class Update extends Thread {

    File dsPath = new File(".");
    ISVNEventHandler eh = new UpdateEventHandler();
    SVNClientManager cm = SVNClientManager.newInstance();
    
    public Update() {
        super();
    }
    
    public void run(){
        try {
            cm.getUpdateClient().setEventHandler(eh);
            SVNUpdateClient uc = cm.getUpdateClient();
            uc.doUpdate(dsPath, SVNRevision.HEAD, SVNDepth.INFINITY, true, true);
        } catch (SVNException ex) {
            JOptionPane.showMessageDialog(null, "Problemas ao efetuar atualização, tente novamente mais tarde.");
        }
    }
    
}
